<template>
  <div>
    <el-table :data="list" show-summary :summary-method="getSummaries">
      <el-table-column
        prop="city_name"
        label="城市"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="agent_name"
        label="代理商"
        align="center"
      ></el-table-column>
      <el-table-column
        v-if="type === 'month'"
        prop="show_month"
        label="月份"
        width="120"
        align="center">
      </el-table-column>

      <el-table-column
        v-if="type === 'week'"
        prop="week_num"
        label="周"
        width="120"
        align="center">
        <template slot-scope="{row}">
          <p>{{row.week_num}}周</p>
          <p>{{row.week_start.slice(5)}} ~ {{row.week_end.slice(5)}}</p>
        </template>
      </el-table-column>

      <el-table-column
        v-if="type == 'day'"
        prop="show_day"
        label="日期"
        width="120"
        align="center">
      </el-table-column>
      <el-table-column label="收入" align="center">
        <el-table-column prop="shop_income" label="商家收入" align="center">
          <template slot-scope="{ row }">
            {{ moneyUnitCent2Coin(row.shop_income) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="shop_income_ratio"
          label="商家收入环比"
          align="center"
        >
          <template slot-scope="{ row }">
            {{ row.shop_income_ratio }}
          </template>
        </el-table-column>
        <el-table-column
          prop="staff_expenditure"
          label="人才支出"
          align="center"
        >
          <template slot-scope="{ row }">
            {{ moneyUnitCent2Coin(row.staff_expenditure) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="staff_expenditure_ratio"
          label="人才支出环比"
          align="center"
        >
          <template slot-scope="{ row }">
            {{ row.staff_expenditure_ratio }}
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="工时" align="center">
        <el-table-column prop="create_hour" label="下单工时" align="center">
          <template slot-scope="{ row }">
            {{ second2Hour(row.create_hour) }}
          </template>
        </el-table-column>
        <el-table-column prop="assign_hour" label="派单工时" align="center">
          <template slot-scope="{ row }">
            {{ second2Hour(row.assign_hour) }}
          </template>
        </el-table-column>
        <el-table-column prop="finish_hour" label="完成工时" align="center"
          ><template slot-scope="{ row }">
            {{ second2Hour(row.finish_hour) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="finish_hour_ratio"
          label="完成工时环比"
          align="center"
        >
        </el-table-column>
      </el-table-column>
      <el-table-column label="任务" align="center">
        <el-table-column
          prop="finish_task"
          label="完成任务数"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="finish_shop"
          label="完成任务店铺数"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="shop_average_gmv"
          label="店铺均GMV"
          align="center"
        >
        <template slot-scope="{ row }">
            <span v-if="row.shop_average_gmv == '-'">{{ row.shop_average_gmv }}</span>
            <span v-else> {{ moneyUnitCent2Coin(row.shop_average_gmv) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="shop_average_hour"
          label="店铺均工时"
          align="center"
        >
        <template slot-scope="{ row }">
          <span v-if="row.shop_average_hour == '-'">{{ row.shop_average_hour }}</span>
          <span v-else> {{ second2Hour(row.shop_average_hour) }}</span>
        </template>
        </el-table-column>
        <el-table-column
          prop="shop_average_task"
          label="店铺均任务"
          align="center"
        ></el-table-column>
      </el-table-column>
      <el-table-column label="店铺" align="center">
        <el-table-column
          prop="cooperation_shop_active_ratio"
          label="合作店铺活跃率"
          align="center"
        >
          <template slot-scope="{ row }">
            {{ row.cooperation_shop_active_ratio }}
          </template>
        </el-table-column>
        <el-table-column
          prop="employment_shop_active_ratio"
          label="用工店铺活跃率"
          align="center"
          ><template slot-scope="{ row }">
            {{ row.employment_shop_active_ratio }}
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="人才" align="center">
        <el-table-column
          prop="staff_work"
          label="出工人才"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="staff_average_water"
          label="人均流水"
          align="center"
        >
        <template slot-scope="{ row }">
            <span v-if="row.staff_average_water == '-'">{{ row.staff_average_water }}</span>
            <span v-else> {{ moneyUnitCent2Coin(row.staff_average_water) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="staff_average_task"
          label="人均任务"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="staff_average_hour"
          label="人均工时"
          align="center"
          ><template slot-scope="{ row }">
            <span v-if="row.staff_average_hour == '-'">{{ row.staff_average_hour }}</span>
            <span v-else> {{ second2Hour(row.staff_average_hour) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="audit_staff_active_ratio"
          label="审核人才活跃率"
          align="center"
        >
          <template slot-scope="{ row }">
            {{ row.audit_staff_active_ratio }}
          </template>
        </el-table-column>
        <el-table-column
          prop="work_staff_active_ratio"
          label="出工人才活跃率"
          align="center"
          ><template slot-scope="{ row }">
            {{ row.work_staff_active_ratio }}
          </template>
        </el-table-column>
      </el-table-column>
    </el-table>
    <el-pagination
      class="paging"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>
<script>
export default {
  name: "Table",
  data() {
    return {};
  },
  props: {
    type: {
      type: String,
      default: "month",
    },
    list: {
      type: Array,
      default: () => [],
    },
    aggregate: {
      type: Object,
      default: () => {},
    },
    page: {
      type: Number,
      default: 1,
    },
    pageSize: {
      type: Number,
      default: 20,
    },
    total: {
      type: Number,
      default: 0,
    },
  },
  mounted() {},
  created() {},
  methods: {
    handleSizeChange(size) {
      this.$emit("page-size", { size, type: this.type });
    },
    handleCurrentChange(page) {
      this.$emit("page-num", { page, type: this.type });
    },
    getSummaries() {
      try {
        return [
          "总计",
          "-",
          "-",
          this.moneyUnitCent2Coin(this.aggregate.shop_income),
          "-",
          this.moneyUnitCent2Coin(this.aggregate.staff_expenditure),
          "-",
          this.second2Hour(this.aggregate.create_hour),
          this.second2Hour(this.aggregate.assign_hour),
          this.second2Hour(this.aggregate.finish_hour),
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
          "-",
        ];
      } catch (err) {
        console.log("----------err", err);
      }
    },
  },
};
</script>
<style scoped lang="scss">
.el-table {
  >>> .el-table__body-wrapper {
    min-height: auto;
  }
}
.paging {
  text-align: right;
  padding: 20px 0;
}
</style>



// WEBPACK FOOTER //
// src/components/sheet/component/AgileBusinessTable.vue